//---------------------------------------------------------------------------

#ifndef ShipmentDlgH
#define ShipmentDlgH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>

#include "DateUtilities.h"
#include "Error.h"
#include "ShipmentBridge.h"
#include <ComCtrls.hpp>
#include <Grids.hpp>
#include <ToolWin.hpp>

//---------------------------------------------------------------------------
class TfrmShipmentDlg : public TForm
{
__published:	// IDE-managed Components
        TPanel *pnlMain;
        TLabel *lblDate;
        TBitBtn *btnOk;
        TBitBtn *btnHelp;
        TBitBtn *btnCancel;
        TLabel *lblNumber;
        TEdit *edtNumber;
        TLabel *lblAmount;
        TEdit *edtAmount;
        TSpeedButton *btnDate;
        TEdit *edtDate;
        TLabel *lblCurrency;
        TLabel *lblProvider;
        TComboBox *cmbProviders;
        TPanel *Panel1;
        TStringGrid *grdDetails;
        TToolBar *barMain;
        TToolButton *btnAdd;
        TToolButton *btnDelete;
        void __fastcall btnOKClick(TObject *Sender);
        void __fastcall btnDateClick(TObject *Sender);
        void __fastcall FormDestroy(TObject *Sender);
        void __fastcall FormShow(TObject *Sender);
        void __fastcall btnDeleteClick(TObject *Sender);
        void __fastcall btnAddClick(TObject *Sender);
private:
        TDatabase* dbMain;

        TShipmentBridge* bridge;
        TShipment* original;
        TShipment* shipment;
        TProviderBridge* providerBridge;

        TStringList * details;

        void RefreshGrid(bool reload);
        void SetButtonsState( int row);

        void ShowShipment();
        void GatherShipment();
        void AddNewShipment();
        void UpdateShipment();

        void ValidateData();
        void HandleError( TError * e);
        void FillProvidersCombo();
public:
        __fastcall TfrmShipmentDlg(TComponent* Owner, TDatabase* dbMain, TShipmentBridge* bridge, TShipment* shipment);
};
//---------------------------------------------------------------------------
#endif
